/*
 * @Author: sean
 * @Date:   2019-12-24 13:28:15
 * @Last Modified by:   sean
 * @Last Modified time: 2019-12-24 13:54:43
 */
const modulesFiles = require.context('./', true, /\.js$/);

const modules = modulesFiles.keys().reduce((modules, moduleDir) => {
    const modulePath = moduleDir.replace(/^\.\/(.*)\.\w+$/, '$1')

    var moduleArr = modulePath.split('/');

    if (moduleArr.length === 3) {
        let group = moduleArr[0];
        let name = moduleArr[1];

        const value = modulesFiles(moduleDir);

        if (modules[group] == undefined) {
            modules[group] = [];
        }
        modules[group].push(value.default);
    }
    return modules
}, {})

export default modules